<!DOCTYPE html>
<html style="height: 100%">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,
            minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
<div id="container" style="height: 100%"></div>
<script type="text/javascript" src="./echarts.min.js"></script>
<script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
option = null;
var _zr = myChart.getZr();
var mm = new echarts.graphic.Text({
 style: {
  x: _zr.getWidth() / 2,
  y: _zr.getHeight()-40,
  textFill:'black',
  text: '',
  textAlign: 'center',
  textFont : '14px'
 }
}
);
_zr.add(mm);


//mma();
option = {
    tooltip: {
        trigger: 'item',
         formatter: function (params) {
       var res=params.data.name+'<br/>'+params.data.kkey;
       //var res=params.data.kkey;
        if(params.data.kkey == '无数据'){
        }else if(params.data.name=='成交数'){
        res+='单';
        }else{
         res+='人次';
        }
         return  res;
        }
    },
    legend: {
        itemWidth:10,
        itemHeight:7,
        icon:'circle',
        selectedMode:false,
        bottom:'bottom',
        data: ['过店客流','进店客流','成交数']
    },
    calculable: true,
    series: [
        {
            name:'漏斗图',
            type:'funnel',
            left: '10%',
            top: 20,
            //x2: 80,
            bottom: 60,
            width: '80%',
            // height: {totalHeight} - y - y2,
            min: 0,
            max: 100,
            minSize: '0%',
            maxSize: '100%',
            sort: 'descending',
            gap: 2,
            label: {
                normal: {
                    position: 'outsi',
                     formatter: function (params) {
                           //var res=params.data.name+params.data.kkey;
                           var res=params.data.kkey;
                            if(params.data.kkey == '无数据'){
                            }else if(params.data.name=='成交数'){
                            res+='单';
                            }else{
                             res+='人次';
                            }
                         return  res;
                      }
                    }

            },
            labelLine: {
                length: 10,
                lineStyle: {
                    width: 1,
                    type: 'solid'
                }
            },
            itemStyle: {
                borderColor: '#fff',
                borderWidth: 1
            },
            data: [
                {kkey:'无数据',value: 60, name: '过店客流',itemStyle:{color:'#45d07d'}},
                {kkey:'无数据',value: 40, name: '进店客流',itemStyle:{color:'#2e89fa'}},
                {kkey:'无数据',value: 20, name: '成交数',itemStyle:{color:'#f54b5d'}}
            ]
        }
    ]
};

;
if (option && typeof option === "object") {
    myChart.setOption(option, true);
}

function   refreshBoottomTxt(content){
_zr.remove(mm);
mm.style = {
  x: _zr.getWidth() / 2,
  y: _zr.getHeight()-40,
  textFill:'black',
  text:content,
  textAlign: 'center',
  textFont : '26px'
}
_zr.add(mm);
}

function refreshChartData(data1,data2,data3){
option.series[0].data =  [
                {value: 60, name: '过店客流',itemStyle:{color:'#45d07d'},kkey:data1},
                {value: 40, name: '进店客流',itemStyle:{color:'#2e89fa'},kkey:data2},
                {value: 20, name: '成交数',itemStyle:{color:'#f54b5d'},kkey:data3}
            ]
            myChart.setOption(option, true);
}
       </script>
</body>
</html>
